package main

import (
	"github.com/e421083458/golang_common/lib"
	"micro-server/conf"
	"micro-server/router"
	"os"
	"os/signal"
	"runtime"
	"syscall"
)

func main() {
	configPath := "./conf/pro/"
	if runtime.GOOS == "windows" {
		configPath = "./conf/dev/"
	}
	_ = lib.InitModule(configPath, []string{"base", "mysql", "redisModules"})
	defer lib.Destroy()

	// 配置信息 及 常量 加载到内存
	conf.PutIntoMemory()
	// 服务开始（内含 路由设置 和 db 启动）
	router.HttpServerRun()

	// 监控信号 并 死循环
	quit := make(chan os.Signal)
	signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
	<-quit

	// 服务结束
	router.HttpServerStop()
}
